package com.dxy.netty.jsonserialize;

import com.alibaba.fastjson.JSON;

/**
 * @Description JSON序列实现，采用fastjson框架
 * @Author dangxianyue
 * @Date 2023/1/10 10:04
 */
public class JSONSerializer implements Serializer{

    @Override
    public byte[] serialize(Object object) {
        return JSON.toJSONBytes(object);
    }

    @Override
    public <T> T deserialize(Class<T> clazz, byte[] bytes) {
        return JSON.parseObject(bytes, clazz);
    }
}
